package com.qf.controller;

import com.google.gson.Gson;
import com.qf.pojo.BaseResult;
import com.qf.pojo.Car;
import com.qf.serivce.ShortSortSerivce;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@RestController
@RequestMapping("/car")
public class CarController {
    @Autowired
    private ShortSortSerivce shortSortSerivce;

    @RequestMapping(value = "/price.do",method = RequestMethod.GET)
    public BaseResult priceALL(@Param("getid") Integer getid)   {
        List<Car> selectprice = shortSortSerivce.selectprice(getid);
        BaseResult baseResult = new BaseResult();
        baseResult.setCode(1);
        baseResult.setInfo(selectprice);
        return baseResult;
    }

    @RequestMapping(value = "/number.do",method = RequestMethod.GET)
    public BaseResult numberall(@Param("getid") Integer getid) throws IOException {
        List<Car> list = shortSortSerivce.selectAll(getid);
        BaseResult baseResult = new BaseResult();
        baseResult.setCode(1);
        baseResult.setInfo(list);
        return baseResult;
/*
        System.out.println("你好啊啊啊啊啊啊");
        PrintWriter writer = response.getWriter();
        System.out.println(cars);
        if (car!=null){
          writer.write("{\"code\":1}");
      }else {
          writer.write("{\"code\":0}");
      }
      writer.flush();
      writer.close();
    }*/
    }

}
